/*
  Copyright 2002-2003 The University of Texas at Austin
  
    Authors: Anthony Thane <thanea@ices.utexas.edu>
             Vinay Siddavanahalli <skvinay@cs.utexas.edu>
    Advisor: Chandrajit Bajaj <bajaj@cs.utexas.edu>

  This file is part of Volume Rover.

  Volume Rover is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  Volume Rover is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with iotree; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/
#ifndef COLORTABLE_H
#define COLORTABLE_H
#include <QFrame>
#include "XoomedIn.h"
#include "XoomedOut.h"

using namespace PBVP;

class ColorTable : public QFrame 
{
	Q_OBJECT
public:
	///
	ColorTable( QWidget *parent, const char *name = NULL );
	
	///
	ColorTable(); // for use in non UI mode
	
	///
	~ColorTable();

	///
	int MapToPixel(float input, int start, int end);
	
	///
	double MapToDouble(int input, int start, int end);
	
	///
	void GetTransferFunction(double *pMap, int size);
	
	///
	QSize sizeHint() const;
	
	///
	TransferMap getColorTableInformation();
	
	///
	void setValExtents( double minVal, double maxVal );

	///
	const IsocontourMap& getIsocontourMap() const;

	///
	void setSpectrumFunctions(float *isoval, float *area, float *min_vol, float *max_vol, float *gradient);
//	void setContourTree(int numVerts, int numEdges, CTVTX *verts, CTEDGE *edges);

	///
	bool removeIsocontourBar(int index);

	///
	bool removeSandwichedNodes();

	///
	void resetNodes();

public slots:
	///
	void loadMap(const QString& fname);

protected:

	TransferMap m_TransferMap;

	XoomedIn* m_XoomedIn;
	XoomedOut* m_XoomedOut;

signals:
/*	void alphaNodeChanged( int index, double value, double position );
	void alphaNodeExploring( int index, double value, double position );
	void alphaNodeAdded( int index, double value, double position );
	void alphaNodeDeleted( int index, double value, double position );

	void colorNodeChanged( int index, double red, double green, double blue, double position );
	void colorNodeExploring( int index, double red, double green, double blue, double position );
	void colorNodeAdded( int index, double red, double green, double blue, double position );
	void colorNodeDeleted( int index, double red, double green, double blue, double position );
*/
	void isocontourNodeChanged( int index, double isovalue, double R, double G, double B );
	void isocontourNodeColorChanged( int index, double R, double G, double B );
	void isocontourNodeExploring( int index, double isovalue );
	void isocontourNodeAdded( int index, double isovalue, double R, double G, double B );
	void isocontourNodeDeleted( int index );
	void isocontourNodeSaved( int index );

	void functionChanged( );
	void functionExploring( );
	
	void acquireContourSpectrum();
	void acquireContourTree();
	void spectrumFunctionsChanged( float *isoval, float *area, float *min_vol, float *max_vol, float *gradient);

	void everythingChanged();

	void selectedColorNode();
	void selectedIsocontourNode( int index, double isovalue );
	void selectedAlphaNode();

protected slots:
/*	void relayAlphaNodeChanged( int index, double value, double position );
	void relayAlphaNodeExploring( int index, double value, double position );
	void relayAlphaNodeAdded( int index, double value, double position );
	void relayAlphaNodeDeleted( int index, double value, double position );

	void relayColorNodeChanged( int index, double red, double green, double blue, double position );
	void relayColorNodeExploring( int index, double red, double green, double blue, double position );
	void relayColorNodeAdded( int index, double red, double green, double blue, double position );
	void relayColorNodeDeleted( int index, double red, double green, double blue, double position );
*/
	void relayIsocontourNodeChanged( int index, double isovalue, double R, double G, double B );
	void relayIsocontourNodeColorChanged( int index, double R, double G, double B );
	void relayIsocontourNodeExploring( int index, double isovalue );
	void relayIsocontourNodeAdded( int index, double isovalue, double R, double G, double B );
	void relayIsocontourNodeDeleted( int index );
	void relayIsocontourNodeSaved( int index );

	void relayFunctionChanged( );
	void relayFunctionExploring( );

	void relayAcquireContourSpectrum();
	void relayAcquireContourTree();

	void relayEverythingChanged();


	void relaySelectedColorNode();
	void relaySelectedIsocontourNode( int index, double isovalue );
	void relaySelectedAlphaNode();

};

#endif

/********************* transfer function format **********************

Anthony and Vinay are Great.

Alphamap
No of nodes
< no of nodes >
Position and opacity
< Position A >
< Position A >
< Position A >
< Position A >
< Position A >

Colormap
No of nodes
< no of nodes >
Position and colors R, G, B
< Position R G B >
< Position R G B >
< Position R G B >
< Position R G B >
< Position R G B >

Isocontours
No of isovalues
< no of isovalues >
Isovalues
< iso 1 >
< iso 2 >
< iso 3 >
< iso 4 >

********************************************************************/
